import thunk from "redux-thunk";
import * as sagas from '../saga';
import createSagaMiddleware from 'redux-saga';
import {applyMiddleware, compose, createStore} from "redux";
import reducer from "./reducer";

const sagaMiddleware = createSagaMiddleware()
const composeEnhancers =
    window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?
        window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({}) : compose;

const enhancer = composeEnhancers(applyMiddleware(thunk, sagaMiddleware));

const store = createStore(reducer, enhancer);

Object.keys(sagas).forEach(i => {
    sagaMiddleware.run(sagas[i]);
})
export default store;
